package com.ft.oa.web.presalesController;

import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.domain.industrys.Industry;
import com.ft.oa.domain.industrys.IndustryProgress;
import com.ft.oa.service.industryService.IIndustryCustomerRelationService;
import com.ft.oa.service.industryService.IIndustryProgressService;
import com.ft.oa.service.industryService.IIndustryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 售前行业维护Controller
 * 
 * @author baowz
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/industry")
public class IndustryController
{
    @Autowired
    private IIndustryService industryService;
    @Autowired
    private IIndustryCustomerRelationService iIndustryCustomerRelationService;
    @Autowired
    private IIndustryProgressService iIndustryProgressService;
    /**
     * 获取行业信息
     */
    @GetMapping("/viewIndustry")
    private ApiResult viewIndustry(@RequestParam String id){
       return ApiResult.successWithData(industryService.viewIndustry(id));
    }
    /**
     * 添加行业领域主表信息
     */
    @PostMapping("/addhyadvocate")
    private ApiResult addhyadvocate(@RequestBody Industry industry){
        return  ApiResult.builder().code(200).msg("添加行业领域主表信息").data(industryService.addhyadvocate(industry)).build();
    }
    /**
     * 删除行业领域主表信息
     */
    @GetMapping("/dellhyadvocate")
    private ApiResult dellhyadvocate(@RequestParam int industId){
        return  ApiResult.builder().code(200).msg("删除成功").data(industryService.dellhyadvocate(industId)).build();
    }
    /**
     * 获取行业所有
     * @return
     */
    @PostMapping("/viewhyall")
    public ApiResult viewhyall(){
        List<Industry> viewhyall = industryService.viewhyall();
        return ApiResult.builder().code(200).msg("行业接口返回成功").data(viewhyall).build();
    }
    /**
     * updatehost  编辑行业维护主表信息
     */
    @PostMapping("/updatehost")
    public ApiResult updatehost(@RequestBody Industry industry){
        return ApiResult.builder().code(200).msg("行业领域总数").data(industryService.updatehost(industry)).build();
    }
    /**
     * 获取行业领域总数
     * @return
     */
    @PostMapping("/indusnum")
    public ApiResult indusnum(){
        return ApiResult.builder().code(200).msg("行业领域总数").data(industryService.indusnum()).build();
    }
    /**
     * 获取客户总数
     * @return
     */
    @PostMapping("/induclientsnum")
    public ApiResult induclientsnum(){
        return ApiResult.builder().code(200).msg("客户目标总数").data(iIndustryCustomerRelationService.customernum()).build();
    }
    /**
     * 查询行业维护的基本信息
     * @return
     */
    @GetMapping("/industlist")
    public ApiResult list(@RequestParam (required = false)String rqhyname, int page, int size){
        return ApiResult.builder().code(200).msg("行业维护返回成功").data(industryService.selectIndustryById(rqhyname, page, size)).build();
    }
    /**
     * 获取行业记录
     */
    @GetMapping("/record")
    public ApiResult record(@RequestParam String industId,String customId){
        HashMap<String, Object> record = iIndustryProgressService.record(industId,customId);
        return ApiResult.builder().code(200).msg("行业维护客户记录").data(record).build();
        //return ApiResult.simpleSuccess();
    }
    /**
     * 新增客户跟进记录
     */
    @PostMapping("/followuprecord")
    public ApiResult Customerfollowuprecord(@RequestBody IndustryProgress industryProgress){
        iIndustryProgressService.Customerfollowuprecord(industryProgress);
        return ApiResult.simpleSuccess();
    }
}
